<?php
/**
 * Created by PhpStorm.
 * User: lenovo
 * Date: 2021/3/15
 * Time: 16:02
 */

namespace common\models\Author;

use common\models\base\BaseModel;
use common\models\membercate\Membercate;

class Author extends BaseModel
{

    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%author}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['member_cate_id','head_portrait', 'name','desc','background','sex', 'birthday', 'province_id', 'city_id',
                'release_num', 'praised_num', 'fans_num', 'follow_num', 'identity'], 'required'],
            [['created_at', 'updated_at', 'sorts'], 'integer'],
            [['name'], 'string', 'max' => 50],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'member_cate_id' => '作者分类',
            'name' =>'作者',
            'head_portrait' =>'头像',
            'desc' => '简介',
            'background' => '背景图',
            'sex' => '性别',
            'birthday' => '生日',
            'province_id' => '省份',
            'city_id' => '城市',
            'area_id' => '县区',
            'release_num' =>'发布数',
            'praised_num' =>'获赞数',
            'fans_num' => '粉丝数',
            'follow_num' => '关注数',
            'identity' => '身份信息',
            'recommend' => '是否推荐',
            'status' => '状态',
            'created_at' => '创建时间',
            'updated_at' => '修改时间',
            'sorts' => '排序',
        ];
    }
    public function getMemberCate()
    {
        return $this ->hasOne(Membercate::class,['id'=>'member_cate_id']);
    }
}